<?php

class StaticpagesController extends AppController{
    var $name='Staticpages';
    var $components = array('RequestHandler', 'Cookie', 'Captcha', 'Email');
    function beforeFilter() {


        $this->Auth->loginRedirect = array('controller' => 'Dashboard', 'action' => 'index');
        $this->Auth->allow('about_us', 'terms','faq','privacy_policy', 'contact');
    }
    function admin_index(){
        $data=$this->Staticpage->find('all');
        $this->set('staticpages',$data);
    }
    function admin_edit($id){
        $this->Staticpage->id=$id;
        if(empty($this->data)){
            $this->data=$this->Staticpage->read(null,$id);
            
        }else{
            
            $this->Staticpage->save($this->data);
            $this->Session->setFlash('Page saved');
            $this->redirect(array('controller'=>'Staticpages','action'=>'index'));
            
        }
    }
    
    function about_us(){
       $data=$this->Staticpage->find('first',array('conditions'=>array('Staticpage.alias'=>'about_us'))) ;
       $this->set('data',$data);
       $this->set('title_for_layout',$data['Staticpage']['title']);
       $this->set('metadesc',$data['Staticpage']['metadesc']);
       $this->set('tags',$data['Staticpage']['metatags']);
       $this->set('keywords',$data['Staticpage']['metakeywords']);
       
    }
    
    function terms(){
       $data=$this->Staticpage->find('first',array('conditions'=>array('Staticpage.alias'=>'terms'))) ;
       $this->set('data',$data); 
       $this->set('title_for_layout',$data['Staticpage']['title']);
       $this->set('metadesc',$data['Staticpage']['metadesc']);
       $this->set('tags',$data['Staticpage']['metatags']);
       $this->set('keywords',$data['Staticpage']['metakeywords']);
       
    }
     
    function faq(){
       $data=$this->Staticpage->find('first',array('conditions'=>array('Staticpage.alias'=>'faq'))) ;
       $this->set('data',$data); 
       $this->set('title_for_layout',$data['Staticpage']['title']);
       $this->set('metadesc',$data['Staticpage']['metadesc']);
       $this->set('tags',$data['Staticpage']['metatags']);
       $this->set('keywords',$data['Staticpage']['metakeywords']);
       
    }
    
    function privacy_policy(){
       $data=$this->Staticpage->find('first',array('conditions'=>array('Staticpage.alias'=>'privacy_policy'))) ;
       $this->set('data',$data); 
       $this->set('title_for_layout',$data['Staticpage']['title']);
       $this->set('metadesc',$data['Staticpage']['metadesc']);
       $this->set('tags',$data['Staticpage']['metatags']);
       $this->set('keywords',$data['Staticpage']['metakeywords']);
       
    }
    
    function tags_guide(){
       $data=$this->Staticpage->find('first',array('conditions'=>array('Staticpage.alias'=>'tag_guide'))) ;
       $this->set('data',$data);
    
       
    }
    function contact(){     
    }
    
}
?>